package tech.shupi.babytapmobile.database

import androidx.room.Entity
import androidx.room.PrimaryKey
import tech.shupi.babytapmobile.types.Card

/**
 * Room Entity for Card table
 */
@Entity(tableName = "cards")
data class CardEntity(
    @PrimaryKey(autoGenerate = true)
    val id: Int = 0,
    val title: String,
    val front_image: String,
    val back_text: String,
    val audio_path: String? = null,
    val created_at: String,
    val updated_at: String
) {
    /**
     * Convert Entity to Domain Model
     */
    fun toCard(): Card {
        return Card(
            id = id,
            title = title,
            front_image = front_image,
            back_text = back_text,
            audio_path = audio_path,
            created_at = created_at,
            updated_at = updated_at
        )
    }
    
    /**
     * Convert Domain Model to Entity
     */
    companion object {
        fun fromCard(card: Card): CardEntity {
            return CardEntity(
                id = card.id,
                title = card.title,
                front_image = card.front_image,
                back_text = card.back_text,
                audio_path = card.audio_path,
                created_at = card.created_at,
                updated_at = card.updated_at
            )
        }
    }
} 